package com.itheima.web;

import com.alibaba.dubbo.config.annotation.Reference;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.entity.Result;
import com.itheima.pojo.CheckGroup;
import com.itheima.service.CheckGroupService;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RequestMapping("/checkgroup")
@RestController
public class CheckGroupController {
    @Reference
    CheckGroupService checkGroupService;
    @RequestMapping("/add")
    public Result add(@RequestBody CheckGroup checkGroup){
        checkGroupService.add(checkGroup);
        return Result.success("");
    }
    @RequestMapping("/findPage")
    public PageResult findPageBean(@RequestBody QueryPageBean queryPageBean){
       return checkGroupService.findPage(queryPageBean);

    }
    @RequestMapping("/findById4Edit")
    public Result findById4Edit(Integer id){
        Map map=checkGroupService.findById4Edit(id);
        return Result.success("",map);
        //map里面有(检查组的基本信息,所有检查项,用户勾选的集合)
    }
    @RequestMapping("/edit")
    public Result edit(@RequestBody CheckGroup checkGroup){
        checkGroupService.edit(checkGroup);
        return Result.success("");
    }
    @RequestMapping("/findAll")
    public Result fndAll(){
       List<CheckGroup> checkGroups=checkGroupService.findAll();
       return Result.success("",checkGroups);

    }

}
